package com.sjz.bookmark.tree;

import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.ToolWindow;
import com.intellij.openapi.wm.ToolWindowFactory;
import com.intellij.ui.content.Content;
import com.intellij.ui.content.ContentFactory;
import org.jetbrains.annotations.NotNull;

import javax.swing.tree.DefaultMutableTreeNode;

public class MyToolWindowFactory implements ToolWindowFactory {

    @Override
    public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) {
        // 生成树数据
        DefaultMutableTreeNode root = TreeDataGenerator.generateTree();

        MyToolWindow myToolWindow = new MyToolWindow();
        myToolWindow.addItem(new MyObject("/path/to/file1", "File 1"));
        myToolWindow.addItem(new MyObject("/path/to/file2", "File 2"));
        ContentFactory contentFactory = ContentFactory.getInstance();
        Content content = contentFactory.createContent(myToolWindow, "", false);
        toolWindow.getContentManager().addContent(content);
    }
}